﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace MatrixWebApiCore.Common.Data
{

    public interface IRepository<T> where T : class
    { 
        //DataContext GetDataContext { get;}     
        int Add(T entity);
        int Add(IEnumerable<T> entitys);
        int Update(T entity);
        int Delete(T entity);       
        int Delete(Expression<Func<T, bool>> where);
        T Get(Expression<Func<T, bool>> where);
        IQueryable<T> GetList(Expression<Func<T, bool>> where);
        IQueryable<T> GetQuery(); 
        IQueryable<T> GetQuery(Expression<Func<T, bool>> where);        
        IQueryable<T> GetAll();
        T GetAsNoTracking(Expression<Func<T, bool>> where);
        IQueryable<T> GetManyAsNoTracking(Expression<Func<T, bool>> where);       
        IQueryable<T> GetAllAsNoTracking();

        /// <summary>
        /// 检查是否存在
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        bool Any(Expression<Func<T, bool>> where);
        int Count(Expression<Func<T, bool>> where);

        ///// <summary>
        ///// 执行查询语句
        ///// </summary>
        ///// <typeparam name="TS"></typeparam>
        ///// <param name="sql"></param>
        ///// <param name="parameters">参数</param>
        ///// <returns>泛型集合</returns>
        //DbRawSqlQuery<TS> SqlQuery<TS>(string sql, params SqlParameter[] parameters);

        ///// <summary>
        ///// 执行查询语句
        ///// </summary>
        ///// <typeparam name="T"></typeparam>
        ///// <param name="sql"></param>
        ///// <param name="parameters">参数</param>
        //DbRawSqlQuery SqlQuery(Type t, string sql, params SqlParameter[] parameters);

        ///// <summary>
        ///// 执行DML语句
        ///// </summary>
        ///// <param name="sql"></param>
        ///// <param name="parameters"></param>
        //void ExecuteSql(string sql, params SqlParameter[] parameters);
    }
}
